import os
import cv2
import numpy as np
from typing import Tuple, Optional
from PySide6.QtGui import QImage, QPixmap
from concurrent.futures import ThreadPoolExecutor
import threading
from functools import lru_cache

class ImageProcessor:
    """图像处理工具类，提供图像加载、转换和处理功能"""
    
    # 图像缓存
    _image_cache = {}
    _cache_lock = threading.Lock()
    # 缓存大小限制(字节)
    _cache_size_limit = 100 * 1024 * 1024  # 100MB
    
    @classmethod
    def clear_cache(cls):
        """清除图像缓存"""
        with cls._cache_lock:
            cls._image_cache.clear()